home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / lib / perl5 / Net / DBus / Binding / Message / Error.pm next >
Encoding:
Perl POD Document  |  2008-02-20  |  2.8 KB  |  125 lines

  1. # -*- perl -*-
  2. #
  3. # Copyright (C) 2004-2006 Daniel P. Berrange
  4. #
  5. # This program is free software; You can redistribute it and/or modify
  6. # it under the same terms as Perl itself. Either:
  7. #
  8. # a) the GNU General Public License as published by the Free
  9. #   Software Foundation; either version 2, or (at your option) any
  10. #   later version,
  11. #
  12. # or
  13. #
  14. # b) the "Artistic License"
  15. #
  16. # The file "COPYING" distributed along with this file provides full
  17. # details of the terms and conditions of the two licenses.
  18.  
  19. =pod
  20.  
  21. =head1 NAME
  22.  
  23. Net::DBus::Binding::Message::Error - a message encoding a method call error
  24.  
  25. =head1 SYNOPSIS
  26.  
  27.   use Net::DBus::Binding::Message::Error;
  28.  
  29.   my $error = Net::DBus::Binding::Message::Error->new(
  30.       replyto => $method_call,
  31.       name => "org.example.myobject.FooException",
  32.       description => "Unable to do Foo when updating bar");
  33.  
  34.   $connection->send($error);
  35.  
  36. =head1 DESCRIPTION
  37.  
  38. This module is part of the low-level DBus binding APIs, and
  39. should not be used by application code. No guarentees are made
  40. about APIs under the C<Net::DBus::Binding::> namespace being
  41. stable across releases.
  42.  
  43. This module provides a convenience constructor for creating
  44. a message representing an error condition. 
  45.  
  46. =head1 METHODS
  47.  
  48. =over 4
  49.  
  50. =cut
  51.  
  52. package Net::DBus::Binding::Message::Error;
  53.  
  54. use 5.006;
  55. use strict;
  56. use warnings;
  57.  
  58. use Net::DBus;
  59. use base qw(Net::DBus::Binding::Message);
  60.  
  61. =item my $error = Net::DBus::Binding::Message::Error->new(
  62.       replyto => $method_call, name => $name, description => $description);
  63.  
  64. Creates a new message, representing an error which occurred during
  65. the handling of the method call object passed in as the C<replyto>
  66. parameter. The C<name> parameter is the formal name of the error
  67. condition, while the C<description> is a short piece of text giving
  68. more specific information on the error.
  69.  
  70. =cut
  71.  
  72. sub new {
  73.     my $proto = shift;
  74.     my $class = ref($proto) || $proto;
  75.     my %params = @_;
  76.  
  77.     my $replyto = exists $params{replyto} ? $params{replyto} : die "replyto parameter is required";
  78.  
  79.     my $msg = exists $params{message} ? $params{message} : 
  80.     Net::DBus::Binding::Message::Error::_create
  81.     (
  82.      $replyto->{message},
  83.      ($params{name} ? $params{name} : die "name parameter is required"),
  84.      ($params{description} ? $params{description} : die "description parameter is required"));
  85.  
  86.     my $self = $class->SUPER::new(message => $msg);
  87.  
  88.     bless $self, $class;
  89.     
  90.     return $self;
  91. }
  92.  
  93. =item my $name = $error->get_error_name
  94.  
  95. Returns the formal name of the error, as previously passed in via
  96. the C<name> parameter in the constructor.
  97.  
  98. =cut
  99.  
  100. sub get_error_name {
  101.     my $self = shift;
  102.     
  103.     return $self->{message}->dbus_message_get_error_name;
  104. }
  105.  
  106. 1;
  107.  
  108. __END__
  109.  
  110. =back
  111.  
  112. =head1 AUTHOR
  113.  
  114. Daniel P. Berrange.
  115.  
  116. =head1 COPYRIGHT
  117.  
  118. Copyright (C) 2005-2006 Daniel P. Berrange
  119.  
  120. =head1 SEE ALSO
  121.  
  122. L<Net::DBus::Binding::Message>
  123.  
  124. =cut
  125.